package com.pactera.madp.daemon.quartz.task;

import com.pactera.madp.common.core.constant.SecurityConstants;
import com.pactera.madp.cp.api.feign.RemoteMomentsTaskService;
import com.pactera.madp.daemon.quartz.constant.enums.MadpQuartzEnum;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @File name：com.pactera.madp.daemon.quartz.task.MomentsTask
 * @Create on：2022/5/17
 * @Author：tianq
 */
@Slf4j
@Component(value = "momentsTask")
@AllArgsConstructor
public class MomentsTask {

    private RemoteMomentsTaskService remoteMomentsTaskService;

    /**
     * 定时同步朋友圈任务详情
     * @return
     */
    @SneakyThrows
    public String synMomentsTaskDetails(){
        remoteMomentsTaskService.synMomentsTaskDetails(SecurityConstants.FROM_IN);
        return MadpQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType();
    }

    /**
     * 修改朋友圈任务状态
     * @return
     */
    @SneakyThrows
    public String updateStatus(){
        remoteMomentsTaskService.updateStatus(SecurityConstants.FROM_IN);
        return MadpQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType();
    }

    /**
     * 删除过期30天的任务
     * @return
     */
    @SneakyThrows
    public String deleteOverdueTasks(){
        remoteMomentsTaskService.deleteOverdueTasks(SecurityConstants.FROM_IN);
        return MadpQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType();
    }

}
